home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Talking Clock Pro™ 2.0.1 / Talking Clock Pro Source / Controller / Source / util.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-24  |  1.3 KB  |  86 lines  |  [TEXT/CWIE]

  1. /*
  2.  * util.c
  3.  */
  4.  
  5. #include <Types.h>
  6. #include <GestaltEqu.h>
  7. #include <Events.h>
  8.  
  9. #include "util.h"
  10. #include "speech.h"
  11.  
  12.  
  13. Boolean
  14. SpeechAvailable ( void ) {
  15.  
  16. static Boolean cache = 0 , init = 0 ;
  17.  
  18.     if ( ! init ) {
  19.         cache = CheckGestaltBit ( gestaltSpeechAttr , gestaltSpeechMgrPresent ) ;
  20.         init = 1 ;
  21.     }
  22.     return cache ;
  23. }
  24.  
  25.  
  26. Boolean
  27. ColorAvailable ( void ) {
  28.  
  29. static Boolean cache = 0 , init = 0 ;
  30. long gResp ;
  31.  
  32.     if ( ! init ) {
  33.         cache = ! ( Gestalt ( gestaltQuickdrawVersion , & gResp ) ||
  34.         ( gResp < 0x100 ) ) ;
  35.         init = 1 ;
  36.     }
  37.     return cache ;
  38. }
  39.  
  40.  
  41. Boolean
  42. OffscreenAvailable ( void ) {
  43.  
  44. static Boolean cache = 0 , init = 0 ;
  45.  
  46.     if ( ! init ) {
  47.         cache = CheckGestaltBit ( gestaltQuickdrawFeatures , gestaltHasDeepGWorlds ) ;
  48.         init = 1 ;
  49.     }
  50.     return cache ;
  51. }
  52.  
  53.  
  54. Boolean
  55. KeyIsDown ( unsigned short keyCode ) {
  56.  
  57. unsigned char keyMap [ 16 ] ;
  58.  
  59.     GetKeys ( ( void * ) keyMap ) ;
  60.     return 1 & ( keyMap [ keyCode >> 3 ] >> ( keyCode & 7 ) ) ;
  61. }
  62.  
  63.  
  64. Boolean
  65. CheckGestaltBit ( long selector , long bitNumber ) {
  66.  
  67. long resp ;
  68.  
  69.     if ( Gestalt ( selector , & resp ) || ! ( resp & ( 1 << bitNumber ) ) ) {
  70.         return 0 ;
  71.     }
  72.     return 1 ;
  73. }
  74.  
  75.  
  76. OSErr
  77. SysSpeakString ( unsigned char * str ) {
  78.  
  79. OSErr ret ;
  80.  
  81.     SetZone ( SystemZone ( ) ) ; /* SysZone */
  82.     ret = SpeakString ( str ) ;
  83.     SetZone ( ApplicZone ( ) ) ;
  84.     return ret ;
  85. }
  86.